package com.gitee.wsl.time.schedule.cron.dsl

import com.gitee.wsl.time.schedule.cron.intToByteConverter
import com.gitee.wsl.time.schedule.cron.monthRange
import kotlinx.datetime.Month

class MonthsBuilder : TimeBuilder<Byte>(monthRange, intToByteConverter){
    /**
     * Will include all variations from this array inside of this timeline
     */
    @Suppress("MemberVisibilityCanBePrivate")
    infix fun include(array: Array<Month>) = include(array.map { it.ordinal }.toTypedArray())

    /**
     * Add one [value] to current timeline
     */
    @Suppress("unused")
    infix fun at(value: Month) = at(value.ordinal)

    /**
     * Shortcut for [at]. In fact will
     */
    @Suppress("unused", "NOTHING_TO_INLINE")
    inline infix fun each(value: Month) = at(value)

    /**
     * Just wrapper for more obvious writing something like "[from] 2 [every] 5". For example, for [SecondsBuilder] it
     * will mean "[from] second second [every] 5 seconds", or "2, 7, 13, ..."
     */
    @Suppress("NOTHING_TO_INLINE")
    inline infix fun from(value: Month) = value

    /**
     * Will create an sequence of times starting [from] [this] [every] [delay] times. For example, for [SecondsBuilder] it
     * will mean "[from] second second [every] 5 seconds", or "2, 7, 13, ..."
     *
     * @see [from]
     */
    infix fun Month.every(delay: Month) = this.ordinal every delay.ordinal

    /**
     * Will fill up this timeline from [this] up to [endIncluding]
     */
    @Suppress("MemberVisibilityCanBePrivate")
    infix fun Month.upTo(endIncluding: Month) = this.ordinal upTo endIncluding.ordinal

    /**
     * Will fill up this timeline from [this] up to [endIncluding]
     */
    @Suppress("MemberVisibilityCanBePrivate")
    infix operator fun Month.rangeTo(endIncluding: Month) = upTo(endIncluding)
}